<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true"  >
			<block slot="content">巡视任务</block>
		</cu-custom>
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs-swiper activeColor="#f29100" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
		<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
			<swiper-item class="swiper-item">
				<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
					<view class="page-box">
						<view class="order" v-for="(res, index) in orderList[0]" :key="res.id"  >
							<view class="item" v-for="(item, index) in res.goodsList" :key="index" @click="jumpUrl(item)">
								<view class="left">
									<image :src="item.goodsUrl" style="width: 45rpx; height: 120rpx;" mode="aspectFill" ></image>
								</view>
								<view class="left">
									<image :src="item.goodsUrl" style="width: 45rpx; height: 120rpx;" mode="aspectFill" ></image>
								</view>
								<view class="content">
									<view class="title u-line-2">{{ item.title }}</view>
									<view class="type">{{ item.jhksTime }}</view>
									<view class="type">{{ item.jhssTime }}</view>
								</view>
								<view class="right">
								</view>
							</view>
	
						</view>
						<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
					</view>
				</scroll-view>
			</swiper-item>
			
			<swiper-item class="swiper-item">
			<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
				<view class="page-box">
					<view class="order" v-for="(res, index) in orderList[1]" :key="res.id">
						<view class="item" v-for="(item, index) in res.goodsList" :key="index">
							<view class="left">
								<image :src="item.goodsUrl" style="width: 45rpx; height: 120rpx;" mode="aspectFill" ></image>
							</view>
							<view class="left">
								<image :src="item.goodsUrl" style="width: 45rpx; height: 120rpx;" mode="aspectFill" ></image>
							</view>
							<view class="content">
								<view class="title u-line-2">{{ item.title }}</view>
								<view class="type">{{ item.jhksTime }}</view>
								<view class="type">{{ item.jhssTime }}</view>
							</view>
							<view class="right">
							</view>
						</view>
				
					</view>
					<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
				</view>
			</scroll-view>
			</swiper-item>
						
		</swiper>
		</view>
	</view>
</template>

<script>
import {navigateTo} from '../../../utils/common.js'
export default {
	data() {
		return {
			orderList: [[], [], [], []],
			dataList: [
				{
					id: 1,
					store: '夏日流星限定贩卖',
					deal: '交易成功',
					goodsList: [
						{
							goodsUrl: '//img13.360buyimg.com/n7/jfs/t1/103005/7/17719/314825/5e8c19faEb7eed50d/5b81ae4b2f7f3bb7.jpg',
							title: '66kV-宝前线-001-007 巡视任务',
							jhksTime: '计划开始时间：2020-09-16 08:00:00',
							jhssTime: '计划结束时间：2020-09-17 19:00:00',
							price: '348.58',
							number: 2
						},
						{
							goodsUrl: '//img12.360buyimg.com/n7/jfs/t1/102191/19/9072/330688/5e0af7cfE17698872/c91c00d713bf729a.jpg',
							title: '66kV-安琪一线-009-0023 巡视任务',
							jhksTime: '计划开始时间：2020-09-20 16:00:00',
							jhssTime: '计划结束时间：2020-09-25 19:00:00',
							price: '135.00',
							number: 1
						}
					]
				}
				 
			],
			list: [
				{
					name: '待办(55)'
				},
				{
					name: '已办(120)'
				}
			],
			current: 0,
			swiperCurrent: 0,
			tabsHeight: 0,
			dx: 0,
			loadStatus: ['loadmore','loadmore','loadmore','loadmore'],
		};
	},
	onLoad() {
		this.getOrderList(0);
		this.getOrderList(1);
		this.getOrderList(3);
	},
	computed: {
	 
	},
	methods: {
		reachBottom() {
			// 此tab为空数据
			if(this.current != 2) {
				this.loadStatus.splice(this.current,1,"loading")
				setTimeout(() => {
					this.getOrderList(this.current);
				}, 1200);
			}
		},
		// 页面数据
		getOrderList(idx) {
			let index = this.$u.random(0, this.dataList.length - 1);
			let data = JSON.parse(JSON.stringify(this.dataList[index]));
			data.id = this.$u.guid();
			this.orderList[idx].push(data);
			this.loadStatus.splice(this.current,1,"loadmore")
		},
	 
		// tabs通知swiper切换
		change(index) {
			this.swiperCurrent = index;
			//this.getOrderList(index);
		},
		// swiper-item左右移动，通知tabs的滑块跟随移动
		transition({ detail: { dx } }) {
			this.$refs.tabs.setDx(dx);
		},
		// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
		// swiper滑动结束，分别设置tabs和swiper的状态
		animationfinish({ detail: { current } }) {
			this.$refs.tabs.setFinishCurrent(current);
			this.swiperCurrent = current;
			this.current = current;
		},
		jumpUrl(item)
		{
			var data = {
				id: item.number,
			}
			var  url= 'basics/xs/xs2' + '?parm=' + JSON.stringify(data)
			navigateTo(url);
		}
		 
	}
};
</script>

<style>
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
.order {
	width: 710rpx;
	background-color: #ffffff;
	margin: 20rpx auto;
	border-radius: 20rpx;
	box-sizing: border-box;
	padding: 0rpx;
	font-size: 28rpx;
	.top {
		display: flex;
		justify-content: space-between;
		.left {
			display: flex;
			align-items: center;
			.store {
				margin: 0 5rpx;
				font-size: 32rpx;
				font-weight: bold;
			}
		}
		.right {
			color: $u-type-warning-dark;
		}
	}
	.item {
		display: flex;
		margin: 20rpx 0 0;
		.left {
			margin-right: 20rpx;
			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 10rpx;
			}
		}
		.content {
			.title {
				font-size: 28rpx;
				line-height: 50rpx;
			}
			.type {
				margin: 10rpx 0;
				font-size: 24rpx;
				color: $u-tips-color;
			}
			.delivery-time {
				color: #e5d001;
				font-size: 24rpx;
			}
		}
		.right {
			margin-left: 10rpx;
			padding-top: 20rpx;
			text-align: right;
			.decimal {
				font-size: 24rpx;
				margin-top: 4rpx;
			}
			.number {
				color: $u-tips-color;
				font-size: 24rpx;
			}
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 24rpx;
		.total-price {
			font-size: 32rpx;
		}
	}
	.bottom {
		display: flex;
		margin-top: 40rpx;
		padding: 0 10rpx;
		justify-content: space-between;
		align-items: center;
		.btn {
			line-height: 52rpx;
			width: 160rpx;
			border-radius: 26rpx;
			border: 2rpx solid $u-border-color;
			font-size: 26rpx;
			text-align: center;
			color: $u-type-info-dark;
		}
		.evaluate {
			color: $u-type-warning-dark;
			border-color: $u-type-warning-dark;
		}
	}
}
.centre {
	text-align: center;
	margin: 200rpx auto;
	font-size: 32rpx;
	image {
		width: 164rpx;
		height: 164rpx;
		border-radius: 50%;
		margin-bottom: 20rpx;
	}
	.tips {
		font-size: 24rpx;
		color: #999999;
		margin-top: 20rpx;
	}
	.btn {
		margin: 80rpx auto;
		width: 200rpx;
		border-radius: 32rpx;
		line-height: 64rpx;
		color: #ffffff;
		font-size: 26rpx;
		background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
	}
}
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}

</style>
